import fs from "fs";
import path from "path";

export function addFilename(fileAddress: string, suffix: string) {
	const newPath = path
		.basename(fileAddress, path.extname(fileAddress))
		.concat(suffix)
		.concat(path.extname(fileAddress));
	return path.resolve(process.cwd(), newPath);
}

export function safeWrite(fileAddress: string, data: string) {
	fs.writeFile(fileAddress, data, { flag: "a" }, err => {
		if (err !== null) throw err;
	});
}
